﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

class MessDAL
{
    DataAccess acc = new DataAccess();
    internal DataTable getAllMess()
    {
        return acc.executeSelect("getAllMessages");
    }

    internal bool insertMess(string mesDetails)
    {
        SqlParameter[] paraList = new SqlParameter[1];
        paraList[0] = new SqlParameter("@Mes_Details", SqlDbType.NVarChar, 4000);
        paraList[0].Value = mesDetails;
        int check = acc.executeModifier("insertMessages", paraList);
        if (check > 0)
        {
            return true;
        }
        else
        {
            return false;
        }
    }



    internal bool delMess(int mesID)
    {
        SqlParameter[] paraList = new SqlParameter[1];
        paraList[0] = new SqlParameter("@Mes_ID", SqlDbType.Int);
        paraList[0].Value = mesID;
        int check = acc.executeModifier("delMessages", paraList);
        if (check > 0)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    internal bool updateMess(int id, string details)
    {
        SqlParameter[] paraList = new SqlParameter[2];
        paraList[0] = new SqlParameter("@Mes_ID", SqlDbType.Int);
        paraList[0].Value = id;
        paraList[1] = new SqlParameter("@Mes_Details",SqlDbType.NVarChar,4000);
        paraList[1].Value = details;
        int check = acc.executeModifier("updateMessages", paraList);
        if (check > 0)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

   
}
